package pro.cherish.knowledgeumldesignpattern.designPattern.com.cherish.flyweight;


import java.util.HashMap;
import java.util.Map;

//享元工厂类
public class ChessFlyWeightFactory {
//    享元池
    private static Map<String,CherssFlyWeight> map=new HashMap<String,CherssFlyWeight>();

    public static CherssFlyWeight getChess(String color){
        CherssFlyWeight cherssFlyWeight = map.get(color);
        if (cherssFlyWeight!=null){
            return cherssFlyWeight;
        }else {
            CherssFlyWeight cfw=new ConcreteChess(color);
            map.put(color, cfw);
            return cfw;
        }
    }

}
